const app = getApp();
const http = require('../../../utils/http.js')
Page({
    /**
     * 页面的初始数据
     */
    data: {
        TabCur: 1,
        SortMenu: [{id: 1, name: "已付款"}, {id: 0, name: "待付款"}, {id: 2, name: "已退款"}],
        orderList: [],
        isShow: false,
        outTradeNo:"",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this;
        let postData = {status: this.data.TabCur}
        this.selectMyOrderLit(postData)
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    selectMyOrderLit(data) {
        http.get('/api/user/selectMyOrderLit', data).then(res => {
            if (res.code == 200) {
                this.setData({
                    orderList: res.result
                })
            }
        })
    },

    tabSelect(e) {
        this.setData({
            TabCur: e.currentTarget.dataset.id
        })
        let postData = {status: this.data.TabCur}
        this.selectMyOrderLit(postData)
    },

    orderClick(e) {
        let index = e.currentTarget.dataset.index;
        let order = this.data.orderList[index];
        if (order.status == 1 && order.sendStatus == 1) {
            this.setData({
                isShow: true,
                outTradeNo: order.outTradeNo
            })
        }
    }
})

